/*
 * Copyright (C) 2016  Nicola Spanti (RyDroid) <dev@nicola-spanti.info>
 * 
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Affero General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 * 
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Affero General Public License for more details.
 * 
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <https://www.gnu.org/licenses/>.
 */


#include "PlanetWars2dRT-core/specific/model/game_state_selection.h"


EXTERN_C_BEGIN


void
game_state_selection_destructor(game_state_selection_t* a_state __attribute__((unused)))
{
  /* Nothing, but may be useful in the future */
}

void
game_state_selection_init_first_time_only(game_state_selection_t* a_state)
{
  SELECTION_2D_GENERIC_INIT_FIRST_TIME_ONLY(a_state->selection);
  a_state->use_selection_to_move_ships = false;
}

void
game_state_selection_clear(game_state_selection_t* a_state)
{
  a_state->selection.state = SELECTION_STATE_NULL;
  a_state->use_selection_to_move_ships = false;
}

void
game_state_selection_starts_rectangle(game_state_selection_t* a_state,
				      unsigned int x,
				      unsigned int y)
{
  a_state->selection.zone.rectangle.position1.x = x;
  a_state->selection.zone.rectangle.position1.y = y;
  a_state->selection.zone.rectangle.position2.x = x;
  a_state->selection.zone.rectangle.position2.y = y;
  a_state->selection.state = SELECTION_STATE_NOT_FINAL;
}

void
game_state_selection_moves_rectangle(game_state_selection_t* a_state,
				     unsigned int x,
				     unsigned int y)
{
  a_state->selection.zone.rectangle.position2.x = x;
  a_state->selection.zone.rectangle.position2.y = y;
}

void
game_state_selection_ends_rectangle(game_state_selection_t* a_state,
				    unsigned int x,
				    unsigned int y)
{
  a_state->selection.zone.rectangle.position2.x = x;
  a_state->selection.zone.rectangle.position2.y = y;
  a_state->selection.state = SELECTION_STATE_FINAL;
}

void
game_state_selection_move_ships(game_state_selection_t* a_state,
				unsigned int x,
				unsigned int y)
{
  a_state->position_to_move_ships.x = x;
  a_state->position_to_move_ships.y = y;
  a_state->use_selection_to_move_ships = true;
}


EXTERN_C_END
